<template>
	<view>
		<!-- 头部 -->
		<view class="header">
			<icons @click="backBeforePage" type="left" color="white" size="22"></icons>
			<view class="">我的会员</view>
		</view>
		<!-- 卡片 -->
		<view class="card">
			<view class="human">
				<view class="icon_box">
					<image class="img1" src="/static/image/yonghu1.png" mode=""></image>
					<image class="img2" src="/static/image/yonghu2.png" mode=""></image>
					<image class="img3" src="/static/image/yonghu3.png" mode=""></image>
					<image class="img4" src="/static/image/yonghu4.png" mode=""></image>
					<image class="img5" src="/static/image/yonghu5.png" mode=""></image>
					<image class="img6" src="/static/image/yonghu6.png" mode=""></image>
				</view>
				<text>5656人已开通会员</text>
				<text class="t1">购买查询</text>
			</view>
			<view class="gold_card">
				<image src="/static/image/huiyuan108.png" mode=""></image>
				<view class="center">
					<image src="/static/image/zu431.png" mode=""></image>
					<view class="login">
						<view class="vip">
							立即登录
							<text>会员</text>
						</view>
						<text>开通会员尊享VIP权益</text>
					</view>
				</view>
			</view>
		</view>
		<!-- // -->
		<view class="choice">
			<view class="mounth">
				<view class="item" @click="changeList(index)" v-for="(item,index) in vipList"
					:class="{active:index == currentIndex}" :key="item._id">
					<text class="t1">{{item.mouth}}个月</text>
					<text class="t2">￥{{item.salePrice}}</text>
					<text class="t3">￥{{item.normalPrice}}</text>
					<view class="recommend" v-if="item.type == 1">
						<image src="/static/image/tuijian.png" mode=""></image>
						<text>推荐</text>
					</view>
				</view>
			</view>
			<view class="nice">
				<image src="/static/image/gongxi@3x.png" mode=""></image>
				<text>您获得2折开通会员特权！</text>
				<text class="t6">恭喜</text>
			</view>
			<view class="btn" @click="close">立即开通</view>
		</view>
		<view class="space"></view>
		<view class="have">
			<text class="title">VIP特权</text>
			<view class="item">
				<image src="/static/image/caipu@3x.png" mode=""></image>
				<view class="item_content">
					<view class="v1">1000+精品名厨</view>
					<view class="v2">大咖教学，轻松学会</view>
				</view>
			</view>
			<view class="item">
				<image src="/static/image/new@3x.png" mode=""></image>
				<view class="item_content">
					<view class="v1">每周上新</view>
					<view class="v2">新菜持续更新中</view>
				</view>
			</view>
			<view class="item">
				<image src="/static/image/ad@3x.png" mode=""></image>
				<view class="item_content">
					<view class="v1">会员免广告打扰</view>
					<view class="v2">体验更流畅</view>
				</view>
			</view>
			<view class="item">
				<image src="/static/image/biaoshi@3x.png" mode=""></image>
				<view class="item_content">
					<view class="v1">VIP尊贵身份标识</view>
					<view class="v2">随时随地，与众不同</view>
				</view>
			</view>
		</view>
		<view class="space"></view>
		<view class="footer">
			<text>会员使用说明</text>
			<view class="title">
				1.会员服务一经开通，不支持退款；
				2.如遇到苹果手机支付问题，建议参考Apptore支付
				流程;
				3.若会员开通出现异常，请立即联系客服，我们会在2
				个工作日内出处理结果。
				4.会员常见问题、会员服务协议、会员隐私协议。
			</view>
		</view>
		<!-- 支付框 -->
		<view v-if="pay_box" class="pay">
			<view class="pay_box">
				<icons type="closeempty" @click="close" size="16" color="#deb062"></icons>
				<view class="pay_t">开通VIP会员</view>
				<view class="mounth">
					<view class="item" @click="changeList(index)" v-for="(item,index) in vipList"
						:class="{active:index == currentIndex}" :key="item._id">
						<text class="t1">{{item.mouth}}个月</text>
						<text class="t2">￥{{item.salePrice}}</text>
						<text class="t3">￥{{item.normalPrice}}</text>
						<view class="recommend" v-if="item.type == 1">
							<image src="/static/image/zhangjia@3x.png" mode=""></image>
							<text>即将涨价</text>
						</view>
					</view>
				</view>
				<view class="nice">
					<image src="/static/image/gongxi@3x.png" mode=""></image>
					<text>开通后立即全站去广告，免费看10000+名厨视频</text>
					<text class="t6">恭喜</text>
				</view>
				<view class="pay_btn" @click="toSuccessPay">
					立即购买
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import icons from "@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
	import {
		getListApi
	} from "../../../apis/mine.js";
	export default {
		mounted() {
			this.getVipList()
		},
		data() {
			return {
				vipList: [],
				currentIndex: 0,
				pay_box:false
			};
		},
		methods: {
			//返回上一页
			backBeforePage() {
				uni.navigateBack()
			},
			//得到套餐列表
			getVipList() {
				getListApi().then(res => {
					this.vipList = res.data
				})
			},
			//改变选中套餐
			changeList(index) {
				this.currentIndex = index
			},
			// 关闭支付框
			close(){
				if(!this.pay_box) this.pay_box = true
				else this.pay_box = false
			},
			//跳转支付成功
			toSuccessPay(){
				const obj = this.vipList[this.currentIndex]
				uni.navigateTo({
					url:"/pages/sub/successPay/successPay?money="+obj.salePrice + "&date="+obj.mouth
				})
			}
		},
		components: {
			icons
		}
	}
</script>

<style lang="scss" scoped>
	//头部
	.header {
		width: 100%;
		height: 150rpx;
		background-color: #313131;
		;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1;

		view {
			padding-top: 25rpx;
			line-height: 160rpx;
			text-align: center;
			color: #ffffff;
			font-size: 36rpx;
			font-weight: 550;
		}

		icons {
			position: absolute;
			top: 80rpx;
			left: 20rpx
		}
	}

	//卡片
	.card {
		padding-top: 160rpx;
		height: 350rpx;
		background-color: #313131;
		border-radius: 0 0 160rpx 160rpx;
		position: relative;

		.human {
			width: 434rpx;
			height: 48rpx;
			background-color: #5c5c5c;
			margin-top: 10rpx;
			border-radius: 0 40rpx 40rpx 0;
			display: flex;
			justify-content: center;
			align-items: center;

			.icon_box {
				width: 180rpx;
				height: 100%;
				position: relative;

				image {
					position: absolute;
					width: 36rpx;
					height: 36rpx;
				}

				.img1 {
					top: 6rpx;
					left: 0rpx;
				}

				.img2 {
					top: 6rpx;
					left: 25rpx;
				}

				.img3 {
					top: 6rpx;
					left: 50rpx;
				}

				.img4 {
					top: 6rpx;
					left: 75rpx;
				}

				.img5 {
					top: 6rpx;
					left: 100rpx;
				}

				.img6 {
					top: 6rpx;
					left: 125rpx;
				}
			}

			text {
				font-size: 24rpx;
				color: #ffffff;
			}

			.t1 {
				position: absolute;
				font-size: 28rpx;
				color: #ffffff;
				right: 32rpx;
			}
		}

		.gold_card {
			width: 100%;
			height: 300rpx;
			position: absolute;
			bottom: -40rpx;

			image {
				width: 100%;
				height: 100%;
			}

			.center {
				width: 400rpx;
				height: 108rpx;
				position: absolute;
				top: 80rpx;
				left: 64rpx;
				display: flex;

				image {
					width: 108rpx;
					height: 108rpx;
					margin-right: 18rpx;
				}

				.login {
					height: 108rpx;

					.vip {
						margin-top: 8rpx;
						font-size: 40rpx;
						color: #7b5b21;
						font-weight: 550;

						text {
							margin-left: 8rpx;
							display: inline-block;
							font-size: 28rpx;
							color: #fbedc5;
							text-align: center;
							line-height: 32rpx;
							width: 106rpx;
							height: 32rpx;
							font-weight: normal;
							background-color: #a5a5a5;
							border-radius: 16rpx;
						}
					}

					text {
						font-size: 28rpx;
						color: #7b5b21;
					}
				}
			}
		}
	}

	//
	.choice {
		padding: 90rpx 32rpx 74rpx;
		box-sizing: border-box;

		.mounth {
			display: grid;
			grid-template-columns: repeat(3, 1fr);
			gap: 24rpx;

			.item {
				box-sizing: border-box;
				padding-top: 20rpx;
				height: 232rpx;
				border: 1rpx solid #e0e0e0;
				border-radius: 16rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-evenly;
				align-items: center;
				font-size: 36rpx;
				font-weight: 550;
				position: relative;

				.t1 {
					color: #464646;
				}

				.t2 {
					color: #deb264;
				}

				.t3 {
					color: #a49fa0;
					text-decoration: line-through;
				}

				.recommend {
					width: 100rpx;
					height: 48rpx;
					position: absolute;
					top: -20rpx;
					left: 0;

					image {
						width: 100%;
						height: 100%;
					}

					text {
						font-size: 26rpx;
						color: #ffffff;
						position: absolute;
						left: 18rpx;
						top: 8rpx;
						font-weight: 550;
					}
				}
			}

			.active {
				border-color: #dcb66a;
				background-color: #fbf7ef;
			}
		}

		.nice {
			margin-top: 26rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			position: relative;

			image {
				width: 92rpx;
				height: 42rpx;
			}

			text {
				font-size: 28rpx;
				color: #7b5b21;
			}

			.t6 {
				font-size: 26rpx;
				color: #deb264;
				position: absolute;
				left: 18rpx;
			}
		}

		//按钮
		.btn {
			margin-top: 50rpx;
			width: 100%;
			height: 80rpx;
			background-color: #fcf1d3;
			border-radius: 16rpx;
			line-height: 80rpx;
			text-align: center;
			font-size: 40rpx;
			color: #a98c4f;
			font-weight: bold;
		}

		//
	}

	//
	.space {
		height: 28rpx;
		background-color: #f5f7fa;
	}

	//vip特权
	.have {
		padding: 18rpx 32rpx 54rpx;

		.title {
			font-size: 44rpx;
			color: #353535;
			font-weight: 550;
		}

		.item {
			box-sizing: border-box;
			padding: 44rpx 14rpx 0;
			display: flex;
			justify-content: flex-start;
			align-items: center;

			image {
				width: 90rpx;
				height: 90rpx;
			}

			.item_content {
				margin-left: 40rpx;

				.v1 {
					font-size: 32rpx;
					color: #212121;
				}

				.v2 {
					font-size: 24rpx;
					color: #aaaaaa;
				}
			}
		}
	}

	//底部
	.footer {
		box-sizing: border-box;
		padding: 20rpx 32rpx 52rpx;

		text {
			font-size: 32rpx;
			color: #232323;
		}

		.title {
			margin-top: 22rpx;
			font-size: 28rpx;
			color: #b7b7b7;
			line-height: 40rpx;
		}
	}

	//支付框
	.pay {
		width: 100%;
		height: 100vh;
		background-color: rgba(#151515, 0.6);
		position: fixed;
		left: 0;
		top: 0;
		z-index: 2;

		.pay_box {
			box-sizing: border-box;
			padding: 26rpx;
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 550rpx;
			background-color: #ffffff;

			icons {
				position: absolute;
				top: 20rpx;
			}

			.pay_t {
				text-align: center;
				font-size: 32rpx;
				color: #5a5a5a;
			}

			.mounth {
				margin-top: 30rpx;
				display: grid;
				grid-template-columns: repeat(3, 1fr);
				gap: 24rpx;

				.item {
					box-sizing: border-box;
					padding-top: 20rpx;
					height: 232rpx;
					border: 1rpx solid #e0e0e0;
					border-radius: 16rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-evenly;
					align-items: center;
					font-size: 36rpx;
					font-weight: 550;
					position: relative;

					.t1 {
						color: #464646;
					}

					.t2 {
						color: #deb264;
					}

					.t3 {
						color: #a49fa0;
						text-decoration: line-through;
					}

					.recommend {
						width: 160rpx;
						height: 56rpx;
						position: absolute;
						top: -35rpx;
						left: 0;

						image {
							width: 100%;
							height: 100%;
						}

						text {
							font-size: 24rpx;
							color: #ffffff;
							position: absolute;
							left: 25rpx;
							top: 16rpx;
							font-weight: 550;
						}
					}
				}

				.active {
					border-color: #dcb66a;
					background-color: #fbf7ef;
				}
			}

			.nice {
				margin-top: 26rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				position: relative;

				image {
					width: 92rpx;
					height: 42rpx;
				}

				text {
					font-size: 24rpx;
					color: #2c2c2c;
					font-weight: 550;
				}

				.t6 {
					font-size: 26rpx;
					color: #deb264;
					position: absolute;
					left: 18rpx;
				}
			}

			.pay_btn {
				width: 100%;
				height: 80rpx;
				background-color: #fcf1d3;
				margin-top: 20rpx;
				border-radius: 16rpx;
				line-height: 80rpx;
				text-align: center;
				font-size: 40rpx;
				color: #a98c4f;
				font-weight: 550;
			}
		}
	}
</style>
